using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Zsa.Emulation.Cartridge;

namespace Zsa.Emulation.CNes.UI
{
    /// <summary>
    /// The cart info class.  Used to show information about a cart.
    /// </summary>
    public partial class CartInfoControl : UserControl
    {
        #region Fields
        /// <summary>
        /// The cart info
        /// </summary>
        private CartridgeFileInfo _CartInf;
        #endregion Fields

        #region Constructor
        /// <summary>
        /// Region the contructor.
        /// </summary>
        public CartInfoControl()
        {
            InitializeComponent();
        }
        #endregion Constructor

        /// <summary>
        /// Shows the cart info on the control.
        /// </summary>
        /// <param name="cartInfo"></param>
        public void ShowInfo(CartridgeFileInfo cartInfo)
        {
            if (cartInfo == null)
            {
                Clear();
                return;
            }
            _CartInf = cartInfo;
            labelChrRomCount.Text = cartInfo.ChrRomBankCount.ToString();
            labelMapper.Text = cartInfo.MapperInformation.ToString();
            labelMD5.Text = cartInfo.RomHash.ToString();
            labelName.Text = cartInfo.FileName;
            labelPath.Text = cartInfo.FilePath;
            labelPrgRomCount.Text = cartInfo.PrgRomBankCount.ToString();
            labelRamCount.Text = cartInfo.RamBankCount.ToString();
            checkBoxFourScreen.Checked = cartInfo.UseFourScreenMirroring;
            checkBoxHasTrainer.Checked = cartInfo.HasTrainer;
            checkBoxIsPal.Checked = cartInfo.IsPal;
            checkBoxRamPack.Checked = cartInfo.HasBatteryPackRam;
            checkBoxVerticalMirror.Checked = cartInfo.UseVerticalMirroring;

        }


        /// <summary>
        /// Clears the cart info
        /// </summary>
        public void Clear()
        {
            _CartInf = null;
            labelChrRomCount.Text = "0";
            labelMapper.Text = string.Empty;
            labelMD5.Text = string.Empty;
            labelName.Text = string.Empty;
            labelPath.Text = string.Empty;
            labelPrgRomCount.Text = "0";
            labelRamCount.Text = "0";
            checkBoxFourScreen.Checked = false;
            checkBoxHasTrainer.Checked = false;
            checkBoxIsPal.Checked = false;
            checkBoxRamPack.Checked = false;
            checkBoxVerticalMirror.Checked = false;
        }

        private void CartInfoControl_Load(object sender, EventArgs e)
        {

        }
    }
}
